class Post < ApplicationRecord
  belongs_to :user
  belongs_to :tag
  has_many :comments, dependent: :destroy
  validates :tag_id, presence: {message:'请填写标签'}
  validates :user_id, presence: true
  default_scope -> { order(created_at: :desc) }
  validates :content, presence: { message: '内容不能为空' }
  validates :content_html, presence: { message: '传入数据错误，请检查您是否允许JavaScript运行！' }
  validates :title, presence: { message: '标题不能为空' }
end
